import { EntitySchema, Ref } from '@mikro-orm/core';
import { OfficeAccounts } from './OfficeAccounts';
import { OfficeNews } from './OfficeNews';
import { Users } from './Users';

export class OfficeNewsSendRecords {
  id!: string;
  news?: Ref<OfficeNews>;
  office?: Ref<OfficeAccounts>;
  createdAt?: Date;
  creator?: Ref<Users>;
  msgId?: string;
  mediaId?: string;
  msgStatus?: string;
  msgOk?: number;
  exception?: string;
}

export const OfficeNewsSendRecordsSchema = new EntitySchema({
  class: OfficeNewsSendRecords,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    news: {
      reference: 'm:1',
      entity: () => OfficeNews,
      ref: true,
      nullable: true,
      index: 'office_news_send_records_ibfk_1',
    },
    office: {
      reference: 'm:1',
      entity: () => OfficeAccounts,
      ref: true,
      nullable: true,
      index: 'office_news_send_records_ibfk_3',
    },
    createdAt: { type: 'Date', length: 0, nullable: true },
    creator: {
      reference: 'm:1',
      entity: () => Users,
      ref: true,
      nullable: true,
      index: 'office_news_send_records_ibfk_2',
    },
    msgId: { type: 'string', length: 500, nullable: true },
    mediaId: { type: 'string', length: 500, nullable: true },
    msgStatus: { type: 'string', length: 500, nullable: true },
    msgOk: { type: 'number', nullable: true },
    exception: { type: 'string', length: 500, nullable: true },
  },
});
